home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-11-21 | 5.0 KB | 191 lines | [TEXT/KAHL] |
- $$Message MM Menu, mm:mmMenu$Prototype.name$.cp
- $$File mm:mmMenu$Prototype.name$.cp
- /* $CopyRight$ */
- /* mmMenu$Prototype.name$ Handle menus
-
- File name: mmMenu$Prototype.name$
- Function: This contains the routines to handle menus.
- History: $Date$ Original by $Author$
-
- */
-
- #include "mmCommon$Prototype.name$.h" /* Common */
- #include "Common$Prototype.name$.h" /* Common */
-
-
- /* ======================================================= */
- /* ======================================================= */
-
- /* Routine: Init */
- /* Purpose: Load in the menu lists and initialize the menubar */
-
- void CmmMenus::Init() /* Initialize the menu bar */
- {
-
- ClearMenuBar(); /* Clear any old menu bars */
-
- $$Loop Menus
- /* This menu is $Menu.FullName$ */
- Menu_$Menu.name$ = GetMenu(Res_Menu_$Menu.name$); /* Get the menu from the resource file */
- InsertMenu(Menu_$Menu.name$,0); /* Insert this menu into the menu bar */
- $$if Menu.Apple
- AddResMenu(Menu_$Menu.name$,'DRVR'); /* Add in DAs */
- $$endif
-
- $$EndLoop Menus
- $$Loop HierMenus
- /* This menu is $Menu.FullName$ */
- Menu_$Menu.name$ = GetMenu(Res_Menu_$Menu.name$); /* Get the menu from the resource file */
- InsertMenu(Menu_$Menu.name$,-1); /* Insert this menu into the menu bar */
-
- $$EndLoop HierMenus
-
- this->AddExtraMenus(); /* Add any extra menu lists */
-
- DrawMenuBar(); /* Draw the menu bar */
- }
-
- /* ======================================================= */
-
- /* Routine: AddExtraMenus */
- /* Purpose: Add in more menus */
-
- void CmmMenus::AddExtraMenus()
- {
- /* Expected to be overridden by the user code */
- }
-
- /* ======================================================= */
-
- /* Routine: EnableTheMenus */
- /* Purpose: Enable or disable menus before they are pulled down */
-
- void CmmMenus::EnableTheMenus()
- {
- /* Expected to be overridden by the user code */
- }
-
- /* ======================================================= */
-
- $$Loop Menus
- /* Routine: DoMenu$Menu.name$ */
- /* Purpose: Handle all menu items in this list */
-
- Boolean CmmMenus::DoMenu$Menu.name$(short theItem)
- {
- $$if Menu.Apple
- short DNA; /* For opening DAs */
- Str255 DAName; /* For getting DA name */
- GrafPtr SavePort; /* Save current port when opening DAs */
- $$endif
- $$if Menu.Edit
- Boolean BoolHolder; /* For SystemEdit result */
- $$endif
- Boolean HandledTheMenuItem;
-
-
- HandledTheMenuItem = true;
- $$if Menu.Edit
- BoolHolder = SystemEdit(theItem - 1); /* Let the DA do the edit to itself */
-
- if (!BoolHolder) /* If not a DA then we get it */
- {
-
- $$endif
- switch (theItem) /* Handle all commands in this menu list */
- {
- $$Loop MenuItems
- case MItem_$MenuItem.name$: /* For item $MenuItem.FullName$ */
- $$Link Menu
- $$if Menu.Quit
- doneFlag = true; /* Quit */
- $$endif
- break;
- $$EndLoop MenuItems
- default: /* allow other buttons, trap for debug */
- $$if Menu.Apple
- GetPort(&SavePort); /* Save the current port */
- GetItem(Menu_$Menu.name$,theItem, DAName); /* Get the name of the DA selected */
- DNA = OpenDeskAcc(DAName); /*Open the DA selected */
- SetPort(SavePort); /* Restore to the saved port */
- $$endif
- HandledTheMenuItem = false;
- break; /* end of otherwise */
- } /* end of switch */
- $$if Menu.Edit
- }
- else
- HandledTheMenuItem = false;
- $$endif
- return(HandledTheMenuItem);
- }
-
- /* ======================================================= */
-
- $$EndLoop Menus
- $$Loop HierMenus
- /* Routine: DoMenu$Menu.name$ */
- /* Purpose: Handle all menu items in this list */
-
- Boolean CmmMenus::DoMenu$Menu.name$(short theItem)
- {
- Boolean HandledTheMenuItem;
-
-
- HandledTheMenuItem = true;
- switch (theItem) /* Handle all commands in this menu list */
- {
- $$Loop MenuItems
- case MItem_$MenuItem.name$: /* For item $MenuItem.FullName$ */
- $$Link Menu
- break;
- $$EndLoop MenuItems
- default: /* allow other buttons, trap for debug */
- HandledTheMenuItem = false;
- break; /* end of otherwise */
- } /* end of switch */
- return(HandledTheMenuItem);
- }
-
- /* ======================================================= */
-
- $$EndLoop HierMenus
- /* ======================================================= */
-
- /* Routine: HandleMenuSelection */
- /* Purpose: Vector off to the appropiate menu list handler */
-
- Boolean CmmMenus::HandleMenuSelection(short theMenu,short theItem)
- {
- Boolean HandledTheMenu;
-
-
- HandledTheMenu = true;
- switch (theMenu) /* Do selected menu list */
- {
- $$Loop Menus
- case Res_Menu_$Menu.name$:
- DoMenu$Menu.name$(theItem); /* Go handle this list, $Menu.FullName$ */
- break;
- $$EndLoop Menus
- $$Loop HierMenus
- case Res_Menu_$Menu.name$:
- DoMenu$Menu.name$(theItem); /* Go handle this list, $Menu.FullName$ */
- break;
- $$EndLoop HierMenus
-
- default: /* allow other buttons, trap for debug */
- HandledTheMenu = false;
- break; /* end of otherwise */
- } /* end of switch */
-
- HiliteMenu(0); /* Turn menu selection off */
- return(HandledTheMenu);
- }
-
- /* ======================================================= */
- /* ======================================================= */
- $$CloseFile
-
-
-